<?php
/*******************************************************
*
* Page:    app_debug.class
* Author:  Matthew Sturges (matt@matthewsturges.com)
* Purpose: Base class for debugging
* Created: 06/29/05
* Version: 2.0
*
* Modified:
*    02/15/05 JAS  debugged table issue
*    03/06/05 MCS  added error checking routine
*
*******************************************************/

class app_debug{

    var $debug_on;
    var $stash_array;

    function app_debug($debug_on){
        //constructor function
        $this->debug_on = $debug_on;
        if ($this->debug_on == 'on'){
            $this->stash_array = array();
            $this->stash_array['DEBUG_START'] = microtime();
        }
    }//end function app_debug

    function STASH($key, $value){
        if ($this->debug_on == 'on'){
            if ($key == 'note'){
                $this->stash_array[note][] = $value;
            } else {
                $this->stash_array[$key] = $value;
            }

        }//end if
    }//end function

    function LOG_TO_FILE($value){
        if ($this->debug_on == 'on'){
            app_lib::log_to_file(APP_DEBUG_LOG_FILE, $value);
        }//end if
    }

    function TRACE(){
        if ($this->debug_on == 'on'){
            global $APP_CACHE;
            echo "<pre style='font-size:11px;background-color:#eeeeee;border:1px solid black;padding:6px;'>\n";
            echo '<br><b>$_GET</b>' . "\n";
            print_r ($_GET);
            echo '<br><b>$_POST</b>' . "\n";
            print_r ($_POST);
            echo '<br><b>$_COOKIE</b>' . "\n";
            print_r ($_COOKIE);
            echo '<br><b>DEBUG STASH</b>' . "\n";
            print_r ($this->stash_array);
            echo '<br><b>CACHE</b>' . "\n";
            print_r ($APP_CACHE);

            $a = $_SERVER;
            unset($a['SERVER_SIGNATURE'], $a['argc'], $a['argv'], $a['HTTP_ACCEPT'], $a['HTTP_COOKIE']);
            echo '<br><b>$_SERVER</b>' . "\n";
            print_r ($a);
            echo "</pre>";
        }//end if
    }


}//end class app_debug

?>
